<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBuildingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('building', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->double('latitude', 10, 6);
            $table->double('longitude', 10, 6);
            $table->integer('area_id')->unsigned();
            $table->integer('agent_id')->unsigned();
            $table->foreign('area_id')->references('id')->on('area');
            $table->foreign('agent_id')->references('id')->on('agent');
            $table->unique(['name', 'agent_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('building');
    }
}
